const app = getApp();
const util = require('../../utils/util.js');
Page({
  data: {
    password: "",
    used_id: 0
  },
  onLoad(options) {
    my.showLoading({
      content: 'loading...'
    });
    let json = JSON.parse(options.data);
    this.setData({
      password: json.password,
      used_id: json.used_id
    });
    my.hideLoading();
    my.alert({
      title: '温馨提示',
      content: '如果输入密码不能充电,请点击【再次获取密码】按钮',
      buttonText: '关闭',
      success: () => {
      }
    });
  },
  // ==================== 跳转到个人用户页面 ==============================
  goToUser() {
    //跳转用户界面
    my.reLaunch({
      url: '../user/user'
    });
  },
  // ==================== 再次获取密码 ======================================
  againGetPwd() {
    my.showLoading({
      content: 'loading...'
    });
    let that = this;
    let used_id = that.data.used_id;
    util.httpRequest('/againGetPwd', {
      used_id: used_id
    }, function (res) {
      my.hideLoading();
      if (res.code == 1) {
        that.setData({
          password: res.data.password
        })
      }
    })
  }
});
